home *** CD-ROM | disk | FTP | other *** search
Java Source | 1999-05-28 | 1.5 KB | 62 lines |
- import java.awt.*;
- import java.util.*;
- import javax.swing.*;
-
- /**
- * <code>HorizontalButtons</code> class layout a button panel in a horizontal orientation
- * @author Jeffrey A. Krzysztow
- * @author Steven R. Brandt
- * @version 1.0
- */
- public class HorizontalButtons extends JPanel {
- /**
- * Constructs a horizontal button panel
- * @since 1.0
- */
- HorizontalButtons() {
- setLayout(gbl);
- gbc.fill = gbc.BOTH;
- gbc.gridy = 0;
- gbc.gridx = 0;
- }
-
- /**
- * adds a button in the next location
- * @param button button to add
- * @since 1.0
- */
- public void add(JButton button) {
- super.add(button);
- bv.addElement(button);
- gbl.setConstraints(button, gbc);
- gbc.gridx++;
- }
-
- /**
- * Enables or disables all the button, depending on the value of the parameter b.
- * @param b if true, buttons are enable, otherwise they are disabled
- * @since 1.0
- */
- public void setEnabled(boolean b) {
- for(int i = 0; i < bv.size(); i++) {
- ((JButton)bv.elementAt(i)).setEnabled(b);
- }
- }
-
- /**
- * Enables or disables the button, depending on the value of the parameter b.
- * @param b if true, buttons are enable, otherwise they are disabled
- * @param index which button
- * @since 1.0
- */
- public void setEnabled(boolean b, int index) {
- ((JButton)bv.elementAt(index)).setEnabled(b);
- }
-
- private GridBagLayout gbl = new GridBagLayout();
- private GridBagConstraints gbc = new GridBagConstraints();
- private Vector bv = new Vector();
-
- }
-
-